package com.bf.electroplating.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bf.electroplating.pojo.dto.IdDTO;
import com.bf.electroplating.pojo.dto.pollution.PollutionPermitDTO;
import com.bf.electroplating.pojo.dto.pollution.PollutionPermitQueryDTO;
import com.bf.electroplating.pojo.vo.ResultVO;
import com.bf.electroplating.pojo.vo.pollution.PollutionPermitVO;
import com.bf.electroplating.service.ComDischargePermitService;
import com.bf.electroplating.util.idempotent.Idempotent;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 排污许可管理控制器
 */
@RestController
@RequestMapping ( "/com-discharge-permit" )
@Tag ( name = "排污许可管理", description = "排污许可管理相关接口" )
public class ComDischargePermitController {

	@Resource
	private ComDischargePermitService permitService;

	@PostMapping ( "/pageList" )
	@Operation ( summary = "分页查询排污许可列表", description = "分页查询排污许可列表" )
	public ResultVO < Page < PollutionPermitVO > > pageList ( @RequestBody PollutionPermitQueryDTO queryDTO ) {
		return permitService.pageList ( queryDTO );
	}

	@Idempotent
	@PostMapping ( "/saveData" )
	@Operation ( summary = "新增/编辑排污许可", description = "新增/编辑排污许可" )
	public ResultVO < String > saveData ( @RequestBody @Validated PollutionPermitDTO dto ) {
		return permitService.saveData ( dto );
	}

	@PostMapping ( "/delete" )
	@Operation ( summary = "删除排污许可", description = "删除排污许可" )
	public ResultVO < String > delete ( @RequestBody List < String > ids ) {
		return permitService.delete ( ids );
	}

	@PostMapping ( "/detail" )
	@Operation ( summary = "获取排污许可详情", description = "获取排污许可详情" )
	public ResultVO < PollutionPermitVO > getDetail ( @RequestBody IdDTO idDTO ) {
		return permitService.getDetail ( idDTO.getId () );
	}
}